<?
include_once('functions.php');
$params[sid] = $sid;
$params[action] = "sales";
$url = "$baseURL/$webDIR/?".encode_params($params);

$params1[sid] = $sid;
$params1[action] = "payment_sales";

if ($errorMsg) {
include_once('errorMsg.html');
}
if ($okMsg) {
include_once('okMsg.html');
}

?>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><font class="text"><b>View Payment History<br>
      <br>
      </b>
A Payment period is one full month.<br>Commission is calculated from the beginning to the end of the month.<br>Payments are done 30 days after the end of the period.<br><a href="#" onClick="show_help('<? echo $rpURL; ?>/payment_info.html')">Click here</a> to see the full 2005/2006 payment schedule.
      </font></td>
  </tr>
</table>
<br><br>
<table class='bTable' cellpadding=0 cellspacing=0>
        <tr>
                <td colspan='5'>Payment History</td>
        </tr>
<!--
        <tr>
                <th><?=translate('period');?></th><th><?=translate('credits');?></th><th colspan=2><?=translate('issue_payment_date');?></th>
        </tr>
-->
        <?
				$result_table .= "<tr>
						<th>Period</th>
						<th>Issued</th>
						<th>Payment Method</th>
						<th>Payment Status</th>
						<th>Amount</th>
						<th>Sales</th>
					<tr>";
				$payment_history = get_payment_history_($id);
				$upcoming = get_reseller_commission($id);
//-------------------------------------------------------------------------------------------------
				if($_SERVER[REMOTE_ADDR]=='83.228.120.103' or $_SERVER[REMOTE_ADDR]=='83.228.120.58'){
	                                $result_table1 = "<tr>
                                                <th>Period</th>
                                                <th>Issued</th>
                                                <th>Payment Method</th>
                                                <th>Payment Status</th>
                                                <th>Amount</th>
                                                <th>Sales</th>
                                        <tr>";	
					$upcoming_periods = get_reseller_commission_($id);
					foreach($upcoming_periods as $period => $line){
	                                        $params1['date'] = '';
        	                                $params1['period'] = $period;
                	                        $url1 = "$baseURL/$webDIR/?".encode_params($params1);

                        	        	$result_table1 .= "<tr>
                                        	        <td align=right>".date('F Y',strtotime($period.'-01'))."</td>
                                                	<td align=center>-</td>
	                                                <td align=center>$line[payment_method]</td>
        	                                        <td align=center>Not Paid</td>
                	                                <td align=right>\$$line[total]</td>
                        	                        <td align=center><a href='$url1' target=_blank>[sales]</a></td>
                                	        <tr>";										
					}
					echo $result_table1;
				}
//-------------------------------------------------------------------------------------------------
				$params1['date'] = '';
				$url1 = "$baseURL/$webDIR/?".encode_params($params1);
				$result_table .= "<tr>
					<td align=right style='border: #FFC9AD ;'>Upcoming</td>
					<td align=center style='border: #FFC9AD ;'>-</td>
					<td align=center style='border: #FFC9AD ;'>$upcoming[payment_method]</td>
					<td align=center style='border: #FFC9AD ;'>none</td>
					<td align=right style='border: #FFC9AD ;'>\$$upcoming[total]</td>
					<td align=right style='border: #FFC9AD ;'><a href='$url1' target=_blank>[sales]</a></td>
				</tr>";
				foreach($payment_history as $k=>$payment){
				$params1['date'] = $payment[issued];
				$url1 = "$baseURL/$webDIR/?".encode_params($params1);
					$result_table .= "<tr>
						<td align=right>$payment[memo]</td>
						<td align=center>$payment[issued]</td>
						<td align=right>$payment[payment_method] ".($payment[payment_method]=='check' ? '[No.'.$payment[check_number].']' : ' '.$payment[paypal_email].'<br>'.$payment[paypal_transaction_id])."</td>
						<td align=right>$payment[status][$payment[change_status_date]]</td>
						<td align=right>\$$payment[amount]</td>
						<td align=right><a href='$url1' target=_blank>[sales]</td>
					<tr>";
				}
				echo $result_table;
        ?>
</TABLE>

<br>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <p><font class="text"><b><br>
			Important - US residents only!<br><br></b>Submit a W-9 form.<br>Please print, completely fill out, and sign a W-9 form found at <a href="http://www.irs.gov/pub/irs-pdf/fw9.pdf" target="_blank">http://www.irs.gov/pub/irs-pdf/fw9.pdf</a><br><br>Individuals - SSN is required,<br>Corporate clients - Tax ID is required. </font><font class="text"><br></font></p><p><font class="text">No commission payments will be sent to US residents without the receipt of the requested W-9 form! <br><br>Completed forms must be sent to <b>Fax</b> # 954 345 1173 or to the following mail address:<br><b>Recipient</b>: Snapy Communications Inc.<br><b>Address</b>: c/o Avalon Accounting 1500 University Drive Suite 117 Coral Springs, FL 33017 USA</font><font class="text"><br><br>To view and print the PDF form you will need a free copy of Adobe Reader
			(<a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">http://www.adobe.com/products/acrobat/readstep2.html</a>).
</font></p>
      </td>
  </tr>
</table>
<p>&nbsp;</p>
